import matplotlib.pyplot as plt
from skimage.data import camera
from skimage.filters import roberts
from skimage import io,color

"""
中文显示工具函数
"""
def set_ch():
    from pylab import mpl
    mpl.rcParams['font.sans-serif']=['FangSong']
    mpl.rcParams['axes.unicode_minus']=False
set_ch()

# image = camera()
image = io.imread('lena.bmp') 
image=color.rgb2gray(image)
edge_roberts = roberts(image)
fig, ax = plt.subplots(ncols=2, sharex=True, sharey=True,
                    figsize=(8, 4))
ax[0].imshow(image, cmap=plt.cm.gray)
ax[0].set_title('原始图像')
ax[1].imshow(edge_roberts, cmap=plt.cm.gray)
ax[1].set_title('Roberts 边缘检测')
for a in ax:
    a.axis('off')
plt.tight_layout()
plt.show()
